package com.cuit.ocp.service.impl;

import com.cuit.ocp.bean.Staff;
import com.cuit.ocp.dao.OcpStaffDao;
import com.cuit.ocp.service.OcpStaffService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class OcpStaffServiceImpl implements OcpStaffService {

    @Resource
    public OcpStaffDao staffDao;

    @Override
    public boolean addNewStaff(Staff new_staff){
        if( staffDao.addNewStaff(new_staff) > 0 )
            return true;
        else
            return false;
    }

    @Override
    public boolean update(Staff staff_info){
        if( staffDao.update(staff_info) > 0 )
            return true;
        else
            return false;
    }

    @Override
    public boolean deleteById(int staff_id){
        if(staffDao.deleteById(staff_id) > 0)
            return true;
        else
            return false;
    }

    @Override
    public boolean deleteByIds(List<Integer> staff_ids){
        if(staffDao.deleteByIds(staff_ids) > 0)
            return true;
        else
            return false;
    }

    @Override
    public List<Staff> findById(int id){
        List<Staff> result = new ArrayList<>();
        result.add(staffDao.findById(id));
            return result;
    }

    @Override
    public List<Staff> findByName(String name){
        List<Staff> result = new ArrayList<>();
        result.add(staffDao.findByName(name));
        return result;
    }

    @Override
    public List<Staff> findAll(){
        List<Staff> result = new ArrayList<>();
        result = staffDao.findAll();
        return result;
    }

}
